package com.jx.mlxg.controller;

import com.jx.mlxg.entity.PaymentRequest;
import com.jx.mlxg.utils.ResponseResult;
import com.jx.mlxg.service.PaymentService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.Data;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

@RestController
@RequestMapping("/pay")
public class PaymentController {

    private  PaymentService paymentService;

    @PostMapping("/create")
    @PreAuthorize("isAuthenticated()")
    public ResponseResult<Map<String, String>> createPayment(@RequestBody PaymentRequest request) {
        return ResponseResult.success(paymentService.createJsapiPayment(request));
    }
//这两个没用了是不
    @PostMapping("/callback")
    public String paymentCallback(HttpServletRequest request) {
        return paymentService.handlePaymentCallback(request);
    }
}